package com.tengju.bff.interfaces.shared;


import java.math.BigDecimal;

public class AmountUtil {

    public static final BigDecimal TEN_THOUSAND = BigDecimal.valueOf(10000L);

    /**
     * >=10000 返回xxW（保留2位小数）  <10000 返回xxx元
     */
    public static String parseToString(BigDecimal amount) {

        if (amount.compareTo(TEN_THOUSAND) >= 0) {
            BigDecimal tenThousandAmount = amount.divide(TEN_THOUSAND, 2);
            return tenThousandAmount.toString() + "W";
        } else {
            return amount.toString() + "元";
        }

    }

    /**
     * 千分位，数字全部展示(double)
     */
    public static String parseToThousandByDouble(BigDecimal amount) {

        if (amount == null) {
            return "0";
        }

        return Formatter.thousandMoney(amount.doubleValue());

    }

    /**
     * 千分位，数字全部展示(int)
     */
    public static String parseToThousandByInt(BigDecimal amount) {

        if (amount == null) {
            return "0";
        }

        return Formatter.thousandMoney(amount.intValue());

    }

}
